<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-01-30
 * Time: 10:16
 */

namespace app\common\model;


use think\Db;
use think\Model;

class Demandcardingm extends Model
{
    /**
     *添加项目需求
     */
    public static function addDemand($data)
    {
        return Db::name('demand_carding')->insertGetId([
                'dc_type'         =>   $data['dc_type'],
                'dc_content'      =>   $data['dc_content'],
                'dc_phone'        =>   $data['dc_phone'],
                'dc_name'         =>   $data['dc_name'],
                'dc_create_time'  =>   time(),
        ]);
    }

    /**
     * 需求信息的列表
     */
    public static function demandList($page)
    {
        return  Db::name('demand_carding')->alias('dc')
            ->join('skill_type', 'dc_type = st_id', 'left')
            ->field('dc.*, st_name')
            ->order('dc_is_look DESC')
            ->order('dc_id DESC')
            ->paginate(15, false, ['page' => $page]);
    }

    /**
     * 需求信息详情
     */
    public static function detail($id)
    {
        Db::name('demand_carding')->where('dc_id', $id)->update(['dc_update_time' => time(), 'dc_is_look' => 2]);
        return  Db::name('demand_carding')->alias('dc')
            ->join('skill_type', 'dc_type = st_id', 'left')
            ->where('dc_id', $id)
            ->field('dc.*, st_name')
            ->find();
    }
}